// 题目链接：https://leetcode.cn/problems/sqrtx/

class Solution
{
public:
    int mySqrt(int x)
    {
        double l = 0, r = x;
        double mid;
        for (int i = 0; i < 100; ++i)
        { // 二分100次，精度已经完全足够了
            mid = (l + r) / 2;
            if (mid * mid <= x)
                l = mid;
            else
                r = mid;
        }

        return l;
    }
};